package com.lujianfei.powersearch.logger;

import com.lujianfei.powersearch.logger.impl.AndroidLogger;
import com.lujianfei.powersearch.logger.impl.JavaLogger;

import java.lang.reflect.Field;

/**
 * 描述:
 * 创建者: lujianfei
 * 日期: 2025/5/20
 */

public class LoggerFactory {
    private static Logger logger;

    static {
        // 伪代码，对于实际部署你可自定义判断
        boolean isAndroid;
        try {
            Class<?> build = Class.forName("android.os.Build");
            Field MANUFACTURER = build.getDeclaredField("MANUFACTURER");
            MANUFACTURER.setAccessible(true);
            isAndroid = MANUFACTURER.get(null) == null ? false: true;
        } catch (Exception e) {
            isAndroid = false;
        }

        if (isAndroid) {
            logger = new AndroidLogger();
        } else {
            logger = new JavaLogger();
        }
    }

    public static Logger getLogger() {
        return logger;
    }
}
